package gsw.demo.mvp.mvp;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ListView;

import java.util.List;

import gsw.demo.mvp.R;
import gsw.demo.mvp.core.net.service.ActivityRetrofitService;
import gsw.demo.mvp.mvp.bean.Girl;
import gsw.demo.mvp.mvp.presenter.GirlPresenter;
import gsw.demo.mvp.mvp.view.IGirlView;
import gsw.demo.mvp.mvp.view.adapter.GirlAdapter;
import gsw.demo.mvp.core.net.rxservice.ActivityRetrofitRxService;
import gsw.demo.mvp.demo.dagger.ActivityDagger;
import gsw.demo.mvp.demo.retrofit.ActivityRetrofit;
import gsw.demo.mvp.mvp_rxbus.ActivityMvpRxBus;

public class MainActivity extends Activity implements IGirlView {
    ListView list;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        list = findViewById(R.id.listview);
    }

    @Override
    public void showGirls(List<Girl> girls) {
        //model层的数据在girls中返回了
        list.setAdapter(new GirlAdapter(this, girls));
    }

    /**
     * 展示MVP
     */
    public void show1(View view) {
        /**
         * Activity只实现UI逻辑和调用Presenter层。
         */
        new GirlPresenter(this).fetch();
    }

    /**
     * Retrofit使用示例
     */
    public void show2(View view) {
        Intent i = new Intent(this, ActivityRetrofit.class);
        startActivity(i);
    }

    /**
     * Dagger使用示例
     */
    public void show3(View view) {
        Intent i = new Intent(this, ActivityDagger.class);
        startActivity(i);
    }

    /**
     * Retrofit直接封装
     */
    public void show4(View view) {
        Intent i = new Intent(this, ActivityRetrofitService.class);
        startActivity(i);
    }

    /**
     * Retrofit使用RxJava封装
     */
    public void show5(View view) {
        Intent i = new Intent(this, ActivityRetrofitRxService.class);
        startActivity(i);
    }

    /**
     * 展示RxBus架构的MVP
     */
    public void show6(View view) {
        Intent i = new Intent(this, ActivityMvpRxBus.class);
        startActivity(i);
    }
}
